<!doctype html>
<html>
	<head>
		<meta charset="utf-8"/>
		<title>
			购物车 查看购物车
		</title>
		<meta name="keywords" content="购物车 查看购物车"/>
		<meta name="description" content="购物车 查看购物车"/>
		<link href="./Public/other/css/orderPublic_v1.css" rel="stylesheet" type="text/css" />
		<link href="./Public/other/css/cart_v1.css" rel="stylesheet" type="text/css" />
		<script src="./Public/other/js/jquery-1.8.1.js"></script>
	</head>
	<body>
		<!-- header -->
		<div class="header clearfix"><?php echo p(Cart::getAllData())?>
			<!--logo样式 -->
			<div class="logo">
				<a href="<?php echo U('Index/index')?>" title="中关村商城">
					<img src="./Public/other/image/shop_212x40.jpg" width="212" height="40">
					<img src="./Public/other/image/logo-text.png" width="165" height="40">
				</a>
			</div>
			<div class="flow-step">
				<ul class="flow-step-1">
					<li class="s1">
						加入购物车
					</li>
					<li class="s2">
						下订单
					</li>
					<li class="s3">
						去付款
					</li>
					<li class="s4">
						确认收货
					</li>
					<li class="s5">
						评价
					</li>
				</ul>
			</div>
		</div>
		<!-- //header -->
		<div class="wrapper">
			<form action="" method="post">
				<input type="hidden" name="buyType" value="2"/>
				<div class="cart-state mt">
					<p>
						购物车状态<em>（<?php echo Cart::getTotalNums();?>）</em>
					</p>
					<div class="total">
						<input name="submitCart" type="submit" value="去结算">
						<span>总计（不含运费）：<em>&yen;</em><em class="total-cart-price"><?php echo Cart::getTotalPrice();?></em></span>
					</div>
				</div>
				<div class="order-table mt20">
					<table width="100%">
						<tr>
							<th class="th-1">
								<label>
									<input name="checkAllCart" type="checkbox" value="1" checked>
									全选</label>
							</th>
							<th class="th-2">
								所选商品
							</th>
							<th class="th-3">
								单价（元）
							</th>
							<th class="th-4">
								数量
							</th>
							<th class="th-5">
								优惠
							</th>
							<th class="th-6">
								小计（元）
							</th>
							<th class="th-7">
								操作
							</th>
						</tr>
						 
						<?php foreach ($c as $k=>$v){?>
						<tr rel="goods-order"  id="cart_<?php echo $k?>">
							<td colspan="2" class="s-infor">
								<input name="cartId[]" type="checkbox" value="<?php echo $k?>" item="item" rel="foritem" checked>
								<a href="<?php echo U('Goods/index',array('gid'=>$v['id']))?>" class="pic" target="_blank">
									<img width="60" height="60" src="<?php echo $d[$k]?>" alt="$v['name']">
								</a>
								<div class="inforbox">
									<h3 class="tit">
										<a href="<?php echo U('Goods/index',array('gid'=>$v['id']))?>" title="$v['name']" target="_blank">
											<?php echo $v['name']?>
										</a>
									</h3>
									<div class="security clearfix">
										<a href="javascript:void(0)" title="7天退换货" class="security-a" >
										</a>
									</div>
									<p>
										<?php foreach (array_slice($v['options'],0,2) as $kk=>$vv){?>
													<?php echo $kk?>：<?php echo $vv?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
										<?php }?>
									</p>
									<div class="info-con">
										<h4>全部规格</h4>
										<div class="info-help">
											<h5>
												全部规格：
											</h5>
											<p>
												<?php foreach ($v['options'] as $kk=>$vv){?>
													<?php echo $kk?>：<?php echo $vv?>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
												<?php }?>
											</p>
										</div>
									</div>
								</div>
							</td>
							<td class="s-price ">
								<em><?php echo $v['price']?></em>
							</td>
							<td class="s-amount ">
								<div class="buy-num">
									<a class="minus" href="javascript:void(0)" title="减一" onClick="$.updateCartnumber({cartId:'<?php echo $k?>', maxNumber:'<?php echo $v['mydata']?>', updateType:'minus', costNumber:'1' })">-</a>
									<input type="text" autocomplete="off" class="text-amount" value="<?php echo $v['num']?>" onBlur="$.updateCartnumber({cartId:'<?php echo $k?>', maxNumber:'<?php echo $v['mydata']?>',updateType:'change', costNumber:'1' })" id="cartNumber_<?php echo $k?>">
									<a class="plus" href="javascript:void(0)" title="加一" onClick="$.updateCartnumber({cartId:'<?php echo $k?>', maxNumber:'<?php echo $v['mydata']?>',updateType:'plus', costNumber:'1' })">+</a>
									<div class="tips-2" id="tips_<?php echo $k?>" style="display:none;">
									</div>
								</div>
							</td>
							<td class="s-agio">
								<div>
									&minus;&minus;
								</div>
							</td>
							<script type="text/javascript">
								
							</script>
							<td class="s-total">
								<em id="cartGoodsPcie_<?php echo $k?>"><?php echo $v['price']*$v['num']?></em>
							</td>
							<td class="s-del">
								<div class="s-delbox">
									<a href="javascript:void(0)" onclick="$.deleteCart({cartId:'<?php echo $k?>'})">
										删除
									</a>
									<div class="deletebox" style="display:none;" id="zp-cart-<?php echo $k?>">
										<p>
											确认要删除该商品吗？
										</p>
										<a href="javascript:void(0)" onclick="$.deleteCart({cartId:'<?php echo $k?>', deleteType:'delete'})">
											是的
										</a>
										<a href="javascript:void(0)" onclick="$.closeDeleteCart({cartId:'<?php echo $k?>'})">
											取消
										</a>
										<i>
										</i>
									</div>
								</div>
							</td>
						</tr>
						<?php }?>
					</table>
					<div class="total-price">
						商品总价<span>（不含运费）</span>：<em>&yen;</em><em class="total-cart-price"><?php echo Cart::getTotalPrice();?></em>
					</div>
					<div class="order-foot clearfix">
						<label>
							<input name="checkAllCart" type="checkbox" value="1" checked>
							全选</label>
						<a href="javascript:void(0)" onclick ="$.deleteAll()">
							批量删除
						</a>
						<a href="javascript:history.back()" class="go-shopping">
							&lt;&lt;继续购物
						</a>
						<input type="submit" value="去结算" name="submitCart" class="accounting-btn">
					</div>
				</div>
			</form>
		</div>
		<div class="footer">
			<p class="links">
				<a target="_blank" href="#">
					关于商城
				</a>|
				<a target="_blank" href="#">
					营销中心
				</a>|
				<a target="_blank" href="#">
					服务中心
				</a>|
				<a target="_blank" href="#">
					联系我们
				</a>|
				<a target="_blank" href="#">
					发展历程
				</a>|
				<a target="_blank" href="#">
					媒体报道
				</a>
			</p>
			<p>
				<span class="copyright">&copy;
					<script type="text/javascript">var yearStr;
now = new Date();
yearStr = now.getFullYear();
document.write(yearStr);</script>中关村在线 版权所有. 京ICP备09041801号-182
					<a target="_blank" href="#">
						京ICP证010391号
					</a></span>
			</p>
		</div>
		<script type="text/javascript">//选中购物车物品样式切换
$("input[name='cartId[]']").click(function() {
	$.changeBackColor();
});
// 套装
$(".info-con").mouseover(function() {
	$(this).addClass("info-con-hover");
}).mouseleave(function() {
	$(this).removeClass("info-con-hover");
});
// 全选
$("input[name=checkAllCart]").click(function() {
	var cartIdArr = new Array();
	if ($(this).is(":checked")) {
		$("input[type=checkbox]").each(function() {
			if (!$(this).is(":checked")) {
				$(this).get(0).checked = true;
			}
			if ('item' == $(this).attr("item")) {
				cartId = parseInt($(this).val());
				if (cartId) {
					cartIdArr.push(cartId);
				}
			}
		});
		$.getCartInfo();
	} else {
		$("input[type=checkbox]").each(function() {
			if ($(this).is(":checked")) {
				$(this).get(0).checked = false;
			}
		});
		$(".total-cart-price").html("0");
		$("input[name=submitCart]").attr("disabled", "true");
	}
	$.changeBackColor();
});
// 显示更多链接
$("#show_more_link").toggle(function() {
	$(".cbsi_zh > p").show();
	$(this).html("收起").attr("class", "more_hov");
}, function() {
	$(".cbsi_zh > p:gt(0)").hide();
	$(this).html("更多").attr("class", "more");
});
$(".agio-limit").mouseover(function() {
	$(this).children("div").show();
}).mouseleave(function() {
	$(this).children("div").hide();
})
$(function($) {
	//遍历处理商品的背景颜色
	$.extend({
		changeBackColor: function() {
			$("input[name='cartId[]']").each(function() {
				var isChecked = $(this).is(":checked");
				var cartVal = $(this).val();
				if (isChecked) {
					$("#cart_" + cartVal).removeClass("other");
				} else {
					$("#cart_" + cartVal).addClass("other");
				}
			});
		}
	});
	$.changeBackColor();
	//获得购物车信息
	$.extend({
		getCartInfo: function() {
			var cartIdArr = new Array();
			var cartIdStr = '';
			var cartId = 0;
			var rel = '';
			$("input[type=checkbox]").each(function() {
				rel = $(this).attr("rel");
				if (('foritem' == rel) && $(this).is(":checked")) {
					cartId = parseInt($(this).val());
					if (cartId) {
						cartIdArr.push(cartId);
					}
				}
			});
			if (cartIdArr.length) {
				cartIdStr = cartIdArr.join(",");
			}
		 
		}
	});
	// 修改购物车数量
	$.extend({
		updateCartnumber: function(options) {
			var defaults = {
				cartId: 0,
				maxNumber: 0,
				costNumber: 0,
				updateType: 'plus'
			};
			var options = $.extend(defaults, options);
			var cartId = defaults.cartId;
			var costNumber = defaults.costNumber;
			var maxNumber = defaults.maxNumber;
			var updateType = defaults.updateType;
			var goodsNumber = $("#cartNumber_" + cartId).val();
			goodsNumber = parseInt(goodsNumber);
			if ((isNaN(goodsNumber)) || (goodsNumber <= 0)) {
				$("#cartNumber_" + cartId).val(costNumber);
				return false;
			}
			// 更新商品类型
			switch (updateType) {
				case 'plus':
					goodsNumber++
					break;
				case 'minus':
					goodsNumber--
					break;
			}
			if (!goodsNumber) {
				goodsNumber = 1;
			}
			if (goodsNumber > maxNumber) {
				goodsNumber = maxNumber;
				$("#tips_" + cartId).html("最多只能购买" + maxNumber + "件").show();
			} else {
				$("#tips_" + cartId).hide();
			}
			$("#cartNumber_" + cartId).val(goodsNumber);
			var cartIdStr = "";
			var cartIdArr = new Array();
			$("input[item=item]").each(function() {
				if (this.checked) {
					cartIdArr.push($(this).val());
				}
			});
			if (cartIdArr.length) {
				cartIdStr = cartIdArr.join(",");
			}
			var noChecked = false;
			if ('' == cartIdStr) {
				noChecked = true;
			}
			 
		}
	});
	// 删除购物
	$.extend({
		deleteCart: function(options) {
			var defaults = {
				cartId: 0,
				deleteType: ''
			};
			var options = $.extend(defaults, options);
			var cartId = defaults.cartId;
			var deleteType = defaults.deleteType;
			var cartIdStr = '';
			if ('' == deleteType) {
				$("#zp-cart-" + cartId).show();
				return false;
			}
			var cartIdArr = new Array();
			$("input[item=item]").each(function() {
				if (this.checked) {
					cartIdArr.push($(this).val());
				}
			});
			cartIdStr = cartIdArr.join(",");
			 
		}
	});
	$.extend({
		closeDeleteCart: function(options) {
			var defaults = {
				cartId: 0
			};
			var options = $.extend(defaults, options);
			var cartId = defaults.cartId;
			$("#zp-cart-" + cartId).hide();
		}
	});
	// 批量删除商品
	$.extend({
		deleteAll: function() {
			var cartIdStr = '';
			var cartIdArr = new Array();
			$("input[item=item]").each(function() {
				if (this.checked) {
					cartIdArr.push($(this).val());
				}
			});
			cartIdStr = cartIdArr.join(",");
			if ('' == cartIdStr) {
				alert("请选择商品");
				return false;
			}
			var conf = confirm("确认要删除选中的商品吗？");
			if (!conf) {
				return false;
			}
			 
		}
	});
})</script>
	</body>
</html>